package com.qianzhou.eduCourseBoot.converter;

import com.qianzhou.eduCommon.dto.CourseDTO;
import com.qianzhou.eduCommon.po.Course;
import com.qianzhou.eduCommon.vo.CourseVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface CourseConverter {
    CourseConverter INSTANCE = Mappers.getMapper(CourseConverter.class);
    /**
     * dto转换为bo mapstruct自定义转换 Cannot find implementation
     */
    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "courseName", target = "courseName"),
            @Mapping(source = "brief", target = "brief"),
            @Mapping(source = "price", target = "price"),
            @Mapping(source = "priceTag", target = "priceTag"),
            @Mapping(source = "discounts", target = "discounts"),
            @Mapping(source = "discountsTag", target = "discountsTag"),
            @Mapping(source = "courseDescriptionMarkDown", target = "courseDescriptionMarkDown"),
            @Mapping(source = "courseDescription", target = "courseDescription"),
            @Mapping(source = "courseImgUrl", target = "courseImgUrl"),
            @Mapping(source = "isNew", target = "isNew"),
            @Mapping(source = "isNewDes", target = "isNewDes"),
            @Mapping(source = "lastOperatorId", target = "lastOperatorId"),
            @Mapping(source = "autoOnlineTime", target = "autoOnlineTime"),
            @Mapping(source = "createTime", target = "createTime"),
            @Mapping(source = "updateTime", target = "updateTime"),
            @Mapping(source = "isDel", target = "isDel"),
            @Mapping(source = "totalDuration", target = "totalDuration"),
            @Mapping(source = "courseListImg", target = "courseListImg"),
            @Mapping(source = "status", target = "status"),
            @Mapping(source = "sortNum", target = "sortNum"),
            @Mapping(source = "previewFirstField", target = "previewFirstField"),
            @Mapping(source = "previewSecondField", target = "previewSecondField"),
            @Mapping(source = "sales", target = "sales"),
    })
    Course dtoConvertPo(CourseDTO dto);
    /**
     * 将bo转换为对应的vo
     */
    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "courseName", target = "courseName"),
            @Mapping(source = "brief", target = "brief"),
            @Mapping(source = "price", target = "price"),
            @Mapping(source = "priceTag", target = "priceTag"),
            @Mapping(source = "discounts", target = "discounts"),
            @Mapping(source = "discountsTag", target = "discountsTag"),
            @Mapping(source = "courseDescriptionMarkDown", target = "courseDescriptionMarkDown"),
            @Mapping(source = "courseDescription", target = "courseDescription"),
            @Mapping(source = "courseImgUrl", target = "courseImgUrl"),
            @Mapping(source = "isNew", target = "isNew"),
            @Mapping(source = "isNewDes", target = "isNewDes"),
            @Mapping(source = "lastOperatorId", target = "lastOperatorId"),
            @Mapping(source = "autoOnlineTime", target = "autoOnlineTime"),
            @Mapping(source = "createTime", target = "createTime"),
            @Mapping(source = "updateTime", target = "updateTime"),
            @Mapping(source = "isDel", target = "isDel"),
            @Mapping(source = "totalDuration", target = "totalDuration"),
            @Mapping(source = "courseListImg", target = "courseListImg"),
            @Mapping(source = "status", target = "status"),
            @Mapping(source = "sortNum", target = "sortNum"),
            @Mapping(source = "previewFirstField", target = "previewFirstField"),
            @Mapping(source = "previewSecondField", target = "previewSecondField"),
            @Mapping(source = "sales", target = "sales"),
    })
    CourseVO poConvertVo(Course course);
}
